package com.redis;

import redis.clients.jedis.*;

import java.util.List;
import java.util.Set;


/**
 * Created by buguniao on 16/4/3.
 */
public class Test {
    public static void main(String[] args){
        JedisPool pool = new JedisPool("localhost",7000);

        Jedis jedis = pool.getResource();
        jedis.slaveofNoOne();

        popList(jedis);

        if(jedis != null){
            jedis.close();
        }
        pool.destroy();
    }

    public static void addToList(Jedis jedis){
        Pipeline pipeline = jedis.pipelined();
        for(int i=0;i<1000;i++){
            pipeline.lpush("curlist","--->"+i);
        }
        pipeline.sync();

        List<String> list = jedis.lrange("curlist",0,-1);
        System.out.println(list);
    }

    public static void popList(Jedis jedis){
        while(true){
            List<String> list = jedis.brpop(3600,"list");
            System.out.println(list);
        }
    }

}
